gtk: Query font size directly
authorBenjamin Otte <otte@redhat.com>
Thu, 6 Dec 2012 01:53:43 +0000 (02:53 +0100)
committerBenjamin Otte <otte@redhat.com>
Thu, 6 Dec 2012 01:57:18 +0000 (02:57 +0100)
... instead of calling gtk_style_context_get_font() and then
pango_font_description_get_size().

gtk/gtkfilechooserdefault.c
gtk/gtkrecentchooserdefault.c

index 72fcdb3609de5997b6f52551487c4b7331976695..19fff36accb9c38aa226b7f7f1d0d1137f4b7e35 100644 (file)
@@ -8187,7 +8187,7 @@ find_good_size_from_style (GtkWidget *widget,
 {
   GtkStyleContext *context;
   GtkStateFlags state;
-  int font_size;
+  double font_size;
   GdkScreen *screen;
   double resolution;
 
@@ -8204,8 +8204,8 @@ find_good_size_from_style (GtkWidget *widget,
   else
     resolution = 96.0; /* wheeee */
 
-  font_size = pango_font_description_get_size (gtk_style_context_get_font (context, state));
-  font_size = PANGO_PIXELS (font_size) * resolution / 72.0;
+  gtk_style_context_get (context, state, "font-size", &font_size, NULL);
+  font_size = font_size * resolution / 72.0 + 0.5;
 
   *width = font_size * NUM_CHARS;
   *height = font_size * NUM_LINES;
index de141d6eb6b65ad2ec00eef3154d9e6d6161e85e..2d15efee8531729192d0c69815f465a4db15a963 100644 (file)
@@ -922,7 +922,7 @@ set_default_size (GtkRecentChooserDefault *impl)
   GtkScrolledWindow *scrollw;
   GtkWidget *widget;
   gint width, height;
-  gint font_size;
+  double font_size;
   GdkScreen *screen;
   gint monitor_num;
   GtkRequisition req;
@@ -935,11 +935,10 @@ set_default_size (GtkRecentChooserDefault *impl)
   state = gtk_widget_get_state_flags (widget);
 
   /* Size based on characters and the icon size */
-  font_size = pango_font_description_get_size (gtk_style_context_get_font (context, state));
-  font_size = PANGO_PIXELS (font_size);
+  gtk_style_context_get (context, state, "font-size", &font_size, NULL);
 
-  width = impl->icon_size + font_size * NUM_CHARS;
-  height = (impl->icon_size + font_size) * NUM_LINES;
+  width = impl->icon_size + font_size * NUM_CHARS + 0.5;
+  height = (impl->icon_size + font_size) * NUM_LINES + 0.5;
 
   /* Use at least the requisition size... */
   gtk_widget_get_preferred_size (widget, &req, NULL);